import os

def read_file(name, **kwds):
    if not kwds.get('encoding') :
        kwds['encoding'] = "utf-8"
        
    f = open(name, **kwds)
    t = f.read()
    f.close()
    return t

def write_file(name, content, **kwds):
    with open(name, "w", **kwds) as f:
        f.write(content)
    return True

def read_file_or_create(name, encoding="utf-8"):
    if not os.path.isfile(name):
        dir_name = os.path.dirname(name)
        if dir_name!="" and dir_name!=".":
            os.makedirs(dir_name)

        open(name, "w").close()
        return ""

    t = read_file(name, encoding=encoding)
    return t

def create_path(*path):
    path = os.path.join(*path)
    if not os.path.exists(path):
        os.makedirs(path)
    
    return path
